package com.genghis.ptas.scorm.entity;


import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;

/**
 * Created with IntelliJ IDEA.
 * User: tiangc
 * Date: 14-5-6
 * Time: 下午5:37
 * To change this template use File | Settings | File Templates.
 */
public class ScormInfoRomMapper implements RowMapper {
    @Override
    public Object mapRow(ResultSet resultSet, int i) throws SQLException {
        ScormInfo scormInfo=new ScormInfo();
        scormInfo.setId(resultSet.getInt("id"));
        scormInfo.setScormName(resultSet.getString("scorm_name"));
        scormInfo.setUploadTime(resultSet.getString("upload_time"));
        scormInfo.setUploadUserId(resultSet.getInt("upload_user_id"));
        scormInfo.setCourseType(resultSet.getInt("course_type"));
        scormInfo.setCourseDisc(resultSet.getString("course_disc"));
        scormInfo.setRegistNum(resultSet.getInt("regist_num"));
        scormInfo.setAvgScore(Double.parseDouble(new DecimalFormat("0.00").format(resultSet.getDouble("comment_score"))));

        scormInfo.setCommentScore(resultSet.getDouble("comment_score"));
        return  scormInfo;
    }
}
